package bishi.yuxin;

import java.util.Scanner;

public class demo2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int l = in.nextInt();
        while(l >0) {
            int n = in.nextInt();
            int[] arry = new int[n];
            for(int i = 0;i < n;i++) {
                arry[i] = in.nextInt();
            }

            int ret = 0;
            for(int i = 0;i < n-1;i++) {
                int sum = arry[i];
                for(int j = i + 1;j < n;j++) {
                    int temp = sum + arry[j];
                    int demo = arry[i] ^ arry[j];
                    if(demo == temp) {
                        ret++;
                    }
                }
            }
            System.out.println(ret);
            l--;
        }
    }
}
